package com.study.designPattern.structure.proxy;



/**
 * @author ysy
 * @version 1.0
 * @Title: ProxyCar
 * @Note <b>ProjectName:</b> cusc-venus
 * <br><b>PackageName:</b> com.cusc.venus.acc.center.util.designPattern.proxy
 * <br><b>ClassName:</b>
 * <br><b>Date:</b>
 *
 */
public class ProxyCar implements Car{

    private RealCar car;

    private String brand;

    public ProxyCar(String brand) {
        this.brand = brand;
    }

    // 代理类，减少RealCar对象加载的内存占用
    @Override
    public void drive() {
        if(car == null){
            car = new RealCar(brand);
        }
        car.drive();
    }
}
